package lab03.test14;

import com.mysql.cj.api.mysqla.result.Resultset;

import javax.xml.transform.Result;
import java.sql.*;

public class Test {

    public static void main(String[] args) {


        //3+1
        Connection connection=null;
        Statement statement=null;
        ResultSet resultset=null;
        String sql="select*from t_userinfo";


        try {
            //加载驱动程序
            Class.forName("com.mysql.jdbc.Driver");
            connection= DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/java_2017?serverTimezone=UTC",
                    "root",
                    "123456"
            );
            statement=connection.createStatement();
            resultset= (ResultSet) statement.executeQuery(sql);

            while(resultset.next()){
                System.out.println(resultset.getString(1));
                System.out.println(resultset.getString(2));
                System.out.println(resultset.getString(3));
                System.out.println(resultset.getString(4));
            }

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            try {
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                statement.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}